home *** CD-ROM | disk | FTP | other *** search
- Path: prairienet.org!sjmccaug
- From: sjmccaug@prairienet.org (Scott J. McCaughrin)
- Newsgroups: comp.lang.c++
- Subject: Re: Help: Can't extract fractional digits of DOUBLE
- Date: 28 Mar 1996 00:23:54 GMT
- Organization: University of Illinois at Urbana
- Message-ID: <4jcm6q$6vm@vixen.cso.uiuc.edu>
- References: <4jc9r7$hnf@nuacht.iol.ie> <4jc3cc$5nj@atlas.tncnet.com>
- Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
- NNTP-Posting-Host: firefly.prairienet.org
-
-
- In a previous article, Goyra@iol.ie (David Byrden) says:
-
- >Simon Lee (Simon Lee) wrote:
- >>
- >>Hello everyone,
- >>
- >>I'm trying to take a double value and extract each digit from the value.
- >
- >
- How are are you assuming the double's representation -- as a fraction
- or in scientific notation? One way to simplify your task is to take
- advantage of the function 'frexp' which does the following:
-
- Every non-zero number can be written uniquely as x * 2**n,
- where the significant x is in the range 0.5 <= |x| < 1.0 and
- the exponent n is an integer. The function frexp() returns
- the significand of a double value as a double quantity, x,
- and stores the exponent n, indirectly through eptr. If
- value == 0, both results returned by frexp() are 0.
-
- Here is the prototype: double frexp(double value, int *eptr)
-
- Now at least you have a number x = frexp(value, &n) in the range
- 0.5 ... 1 that you can more easily strip digits from than an arb-
- trary double.
-
-
-